package com.cheer.vo;

import com.cheer.enums.TitleEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.text.NumberFormat;
import java.util.Date;
import java.util.List;

@Data
@ApiModel("参评列表")
public class ApplicantReferenceListVO {

    @ApiModelProperty("参评主键值")
    private Long id;

    @ApiModelProperty("账号ID")
    private Long accountId;

    @ApiModelProperty("集体ID")
    private Long applicantId;

    @ApiModelProperty("集体名称")
    private String applicantName;

    @ApiModelProperty("报送组织")
    private String reportOrgName;

    @ApiModelProperty("所属组织")
    private String orgName;

    @ApiModelProperty("45周岁以下负责人姓名")
    private String contactPerson;

    @ApiModelProperty("号长手机号")
    private String phoneAccount;

    @ApiModelProperty("职工人数")
    private Integer personNumber;

    @ApiModelProperty("35周岁以下青年人数")
    private Integer youthNumber;

    @ApiModelProperty("35周岁以下青年人数占比")
    private String youthPercent;

    @ApiModelProperty("荣誉等级")
    private Integer title;

    @ApiModelProperty("是否获取到")
    private Boolean awarded;

    @ApiModelProperty("注册的荣誉称号")
    private Integer registerTitle;

    @ApiModelProperty("荣誉级别")
    private Integer starNum;

    @ApiModelProperty("获得年份")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private String titleYear;

    @ApiModelProperty("是否是联合审批 1 本机构 2 联合审批")
    private Integer reviewType;

    @ApiModelProperty("参评申请日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date applyTime;

    @ApiModelProperty("简要事迹")
    private String achievement;

    @ApiModelProperty("是否报送")
    private Integer isPost;

    @ApiModelProperty("是否授予")
    private Integer isConfer;

    @ApiModelProperty("是否置顶")
    private Integer isTop;

    @ApiModelProperty("是否是特殊推荐")
    private Integer isSpecial;

    @ApiModelProperty("推荐表")
    @NotNull(message = "推荐表不能为空")
    private DocumentVO recommend;

    @ApiModelProperty("事迹材料")
    @NotNull(message = "事迹材料不能为空")
    private DocumentVO story;

    @ApiModelProperty("工作图片")
    @NotNull(message = "工作图片不能为空")
    private List<DocumentVO> evidences;

    @ApiModelProperty("工作图片")
    private List<String> evidenceLinks;

    public void build() {

        if (title == TitleEnum.NO.getType()) {
            this.setTitle(registerTitle);
            this.setAwarded(false);
        } else {
            this.setTitle(title);
            this.setAwarded(true);
        }
        NumberFormat nt = NumberFormat.getPercentInstance();
        if(youthNumber == 0 || personNumber == 0){
            this.setYouthPercent(nt.format(0));
        }else{
            this.setYouthPercent(nt.format(1.0 * youthNumber / personNumber));
        }

    }

}
